# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=kooha
pkgver=2.2.4
pkgrel=0
pkgdesc="Elegantly record your screen"
url="https://github.com/SeaDve/Kooha"
# riscv64: fails to build libc crate
# s390x: no desktop for thish arch
arch="all !riscv64 !s390x"
license="GPL-3.0-or-later"
depends="
	gst-plugin-pipewire
	gst-plugins-good
	pipewire
	xdg-desktop-portal
	"
makedepends="
	cargo
	gettext-dev
	glib-dev
	gst-plugins-base-dev
	gst-plugins-ugly
	gst-vaapi
	gstreamer-dev
	gtk4.0-dev
	libadwaita-dev
	meson
	pulseaudio-dev
	wayland-dev
	x264-dev
	"
checkdepends="
	cmd:desktop-file-validate
	mesa-dri-gallium
	xvfb-run
	"
install="$pkgname.post-install"
subpackages="$pkgname-lang $pkgname-mp4"
source="https://github.com/SeaDve/Kooha/releases/download/v$pkgver/kooha-$pkgver.tar.xz
	fix-tests.patch
	no-clippy.patch
	ignore-i18n-tests.patch
	"

# TODO: Find out why I didn't originally use panic=abort and if it's still relevant.
export CARGO_PROFILE_RELEASE_PANIC="unwind"

prepare() {
	default_prepare

	# TODO: Remove after removing fix-tests.patch.
	cargo vendor --locked
}

build() {
	abuild-meson -Db_lto=true . output
	meson compile -j ${JOBS:-0} -C output
}

check() {
	xvfb-run --auto-servernum meson test --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

mp4() {
	pkgdesc="Kooha dependencies for recording into MP4 format"
	depends="$pkgname=$pkgver-r$pkgrel gst-plugins-ugly"

	mkdir -p "$subpkgdir"
}

sha512sums="
5bd84480b0355d180d78d5faa65f1f7ab15081d1be3fe447c9bf017f0b9b429b5330521f0ee0582a4763a45e3dcf76ef2886a0b7385675a64e1f6fbdaaa644e6  kooha-2.2.4.tar.xz
e2bf21c267d9764bca74846f830939a23d1a976c23dd38a470d79d61eb04621bb3e8a37e820218567e9c80f0f8af1e7d37aac8faea1f120beb072132f26a60fb  fix-tests.patch
98f3a41e399c0d6d9a0a2479f33f6439b265ace3977f703d3fcd6366d43adff421ac859bc803fee0d08d6d1a694a058628f63b14e0dd936dd26c51b0782f4298  no-clippy.patch
95ba2c8fb67dd742ee5787fad4d0f9ce7e89e7275c0425e55a5536878b046097798d1e5c54cf23c398a6f6b00b5c04de7eac9f2a7a05b915ed1dffc599620f2a  ignore-i18n-tests.patch
"
